package com.ruoyi.edge.gateway.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.mybatis.core.page.PageQuery;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.edge.gateway.domain.Concatenate;
import com.ruoyi.edge.gateway.mapper.ConcatenateMapper;
import com.ruoyi.edge.gateway.service.ConcatenateService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 云端连接配置
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class ConcatenateServiceImpl implements ConcatenateService {

    private final ConcatenateMapper concatenateMapper;

    @Override
    public TableDataInfo<Concatenate> listPage(Concatenate concatenate, PageQuery pageQuery) {

        LambdaQueryWrapper<Concatenate> lqw = new LambdaQueryWrapper<>();
        Page<Concatenate> page = concatenateMapper.selectPage(pageQuery.build(), lqw);
        return TableDataInfo.build(page);
    }

    @Override
    public R<Concatenate> get(String id) {
        Concatenate concatenate = concatenateMapper.selectById(id);
        return R.ok(concatenate);
    }

    @Override
    public R<String> add(Concatenate concatenate) {
        concatenateMapper.insert(concatenate);
        return R.ok("新增成功");
    }

    @Override
    public R<String> edit(Concatenate concatenate) {
        concatenateMapper.updateById(concatenate);
        return R.ok("修改成功");
    }

    @Override
    public R<String> remove(String id) {
        concatenateMapper.deleteById(id);
        return R.ok("删除成功");
    }

    @Override
    public R<String> editStatus(String id, Integer status) {
        concatenateMapper.editStatus(id, status);
        return R.ok("修改成功");
    }


}
